package com.example.mobilesafe.receiver;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.telephony.SmsManager;
import android.telephony.TelephonyManager;

import com.example.mobilesafe.constant.ConstantValue;
import com.example.mobilesafe.utils.SharedPreferencesUtil;

public class BootReceiver extends BroadcastReceiver {

    @Override
    public void onReceive(Context context, Intent intent) {
        // 1.获取开启后手机的sim卡的序列号
        TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
        //String simSerialNumber = tm.getSimSerialNumber();
        String simSerialNumber = "SIM卡序列号变化";
        // 2.sp中存储的序列卡号
        String sim_number = SharedPreferencesUtil.getString(context, ConstantValue.SIM_NUMBER, "");
        // 3.比对
        if (!simSerialNumber.equals(sim_number)){
            // 4.发送短信给选中联系人号码
            SmsManager sms = SmsManager.getDefault();
            sms.sendTextMessage("5556",null,"sim Change!!",null,null);
        }
    }
}
